source("process_data.R")
base_columns <- names(store)[!names(store) %in% c("Year", "Month")]
GGally::ggpairs(store, columns = base_columns)
plot: [1,1] [==-----------------------------------------------] 4% est: 0s
plot: [1,2] [====---------------------------------------------] 8% est: 1s
plot: [1,3] [======-------------------------------------------] 12% est: 1s
plot: [1,4] [========-----------------------------------------] 16% est: 1s
plot: [1,5] [==========---------------------------------------] 20% est: 1s
plot: [2,1] [============-------------------------------------] 24% est: 1s
plot: [2,2] [==============-----------------------------------] 28% est: 1s
plot: [2,3] [================---------------------------------] 32% est: 1s
plot: [2,4] [==================-------------------------------] 36% est: 1s
plot: [2,5] [====================-----------------------------] 40% est: 1s
plot: [3,1] [======================---------------------------] 44% est: 1s
plot: [3,2] [========================-------------------------] 48% est: 1s
plot: [3,3] [=========================------------------------] 52% est: 1s
plot: [3,4] [===========================----------------------] 56% est: 1s
plot: [3,5] [=============================--------------------] 60% est: 1s
plot: [4,1] [===============================------------------] 64% est: 1s
plot: [4,2] [=================================----------------] 68% est: 1s
plot: [4,3] [===================================--------------] 72% est: 0s
plot: [4,4] [=====================================------------] 76% est: 0s
plot: [4,5] [=======================================----------] 80% est: 0s
plot: [5,1] [=========================================--------] 84% est: 0s
plot: [5,2] [===========================================------] 88% est: 0s
plot: [5,3] [=============================================----] 92% est: 0s
plot: [5,4] [===============================================--] 96% est: 0s
plot: [5,5] [=================================================]100% est: 0s

GGally::ggpairs(store, columns = c(base_columns, "Year"),
mapping = ggplot2::aes(color = Year))
plot: [1,1] [=------------------------------------------------] 3% est: 0s
plot: [1,2] [===----------------------------------------------] 6% est: 2s
plot: [1,3] [====---------------------------------------------] 8% est: 2s
plot: [1,4] [=====--------------------------------------------] 11% est: 3s
plot: [1,5] [=======------------------------------------------] 14% est: 2s
plot: [1,6] [========-----------------------------------------] 17% est: 2s
plot: [2,1] [==========---------------------------------------] 19% est: 2s
plot: [2,2] [===========--------------------------------------] 22% est: 2s
plot: [2,3] [============-------------------------------------] 25% est: 2s
plot: [2,4] [==============-----------------------------------] 28% est: 2s
plot: [2,5] [===============----------------------------------] 31% est: 2s
plot: [2,6] [================---------------------------------] 33% est: 2s
plot: [3,1] [==================-------------------------------] 36% est: 2s
plot: [3,2] [===================------------------------------] 39% est: 2s
plot: [3,3] [====================-----------------------------] 42% est: 2s
plot: [3,4] [======================---------------------------] 44% est: 2s
plot: [3,5] [=======================--------------------------] 47% est: 2s
plot: [3,6] [========================-------------------------] 50% est: 2s
plot: [4,1] [==========================-----------------------] 53% est: 2s
plot: [4,2] [===========================----------------------] 56% est: 1s
plot: [4,3] [=============================--------------------] 58% est: 1s
plot: [4,4] [==============================-------------------] 61% est: 1s
plot: [4,5] [===============================------------------] 64% est: 1s
plot: [4,6] [=================================----------------] 67% est: 1s
plot: [5,1] [==================================---------------] 69% est: 1s
plot: [5,2] [===================================--------------] 72% est: 1s
plot: [5,3] [=====================================------------] 75% est: 1s
plot: [5,4] [======================================-----------] 78% est: 1s
plot: [5,5] [=======================================----------] 81% est: 1s
plot: [5,6] [=========================================--------] 83% est: 1s
plot: [6,1] [==========================================-------] 86% est: 0s
plot: [6,2] [============================================-----] 89% est: 0s
plot: [6,3] [=============================================----] 92% est: 0s
plot: [6,4] [==============================================---] 94% est: 0s
plot: [6,5] [================================================-] 97% est: 0s
plot: [6,6] [=================================================]100% est: 0s

GGally::ggpairs(category, columns = base_columns,
mapping = ggplot2::aes(color = Category))
plot: [1,1] [==-----------------------------------------------] 4% est: 0s
plot: [1,2] [====---------------------------------------------] 8% est: 2s
plot: [1,3] [======-------------------------------------------] 12% est: 2s
plot: [1,4] [========-----------------------------------------] 16% est: 2s
plot: [1,5] [==========---------------------------------------] 20% est: 2s
plot: [2,1] [============-------------------------------------] 24% est: 1s
plot: [2,2] [==============-----------------------------------] 28% est: 1s
plot: [2,3] [================---------------------------------] 32% est: 1s
plot: [2,4] [==================-------------------------------] 36% est: 1s
plot: [2,5] [====================-----------------------------] 40% est: 1s
plot: [3,1] [======================---------------------------] 44% est: 1s
plot: [3,2] [========================-------------------------] 48% est: 1s
plot: [3,3] [=========================------------------------] 52% est: 1s
plot: [3,4] [===========================----------------------] 56% est: 1s
plot: [3,5] [=============================--------------------] 60% est: 1s
plot: [4,1] [===============================------------------] 64% est: 1s
plot: [4,2] [=================================----------------] 68% est: 1s
plot: [4,3] [===================================--------------] 72% est: 1s
plot: [4,4] [=====================================------------] 76% est: 1s
plot: [4,5] [=======================================----------] 80% est: 0s
plot: [5,1] [=========================================--------] 84% est: 0s
plot: [5,2] [===========================================------] 88% est: 0s
plot: [5,3] [=============================================----] 92% est: 0s
plot: [5,4] [===============================================--] 96% est: 0s
plot: [5,5] [=================================================]100% est: 0s

p <- GGally::ggpairs(type, columns = base_columns,
mapping = ggplot2::aes(color = Type))
plotly::ggplotly(p)
summary(lm_fit)
Call:
lm(formula = Revenue ~ Category + Type + Qty_Sold, data = type)
Residuals:
Min 1Q Median 3Q Max
-9908.3 -829.8 -113.4 669.7 9003.4
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) -2415.49 1016.48 -2.376 0.019095 *
CategoryBikes 15021.33 1057.10 14.210 < 2e-16 ***
TypeHelmets -1374.45 944.01 -1.456 0.148056
TypeHybrid -2954.91 864.20 -3.419 0.000863 ***
TypeKids -9991.63 855.47 -11.680 < 2e-16 ***
TypeMountain -2076.47 852.78 -2.435 0.016391 *
TypeParts -9437.96 2844.83 -3.318 0.001208 **
TypeRoad NA NA NA NA
Qty_Sold 106.17 16.83 6.307 5.14e-09 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2558 on 118 degrees of freedom
Multiple R-squared: 0.7644, Adjusted R-squared: 0.7505
F-statistic: 54.71 on 7 and 118 DF, p-value: < 2.2e-16
type %>%
dplyr::group_by(Category, Type) %>%
dplyr::summarize(min = min(Qty_Sold), median = median(Qty_Sold),
max = max(Qty_Sold))
boot_type <- type %>%
dplyr::select(Category, Type, Qty_Sold) %>%
sample_n(10000, replace = TRUE)
boot_type$Revenue <- predict(lm_fit, boot_type)
percentiles <- boot_type %>%
dplyr::group_by(Category, Type) %>%
dplyr::mutate(percentile = ntile(Qty_Sold, 10)) %>%
dplyr::group_by(Category, Type, percentile) %>%
dplyr::summarize(min = min(Qty_Sold), max = max(Qty_Sold))
LS0tDQp0aXRsZTogIkJpa2UgUGVkZGxlciINCm91dHB1dDogaHRtbF9ub3RlYm9vaw0KLS0tDQoNCg0KDQpgYGB7ciwgd2FybmluZz1GQUxTRSwgbWVzc2FnZT1GQUxTRX0NCnNvdXJjZSgicHJvY2Vzc19kYXRhLlIiKQ0KYmFzZV9jb2x1bW5zIDwtIG5hbWVzKHN0b3JlKVshbmFtZXMoc3RvcmUpICVpbiUgYygiWWVhciIsICJNb250aCIpXQ0KYGBgDQoNCmBgYHtyfQ0KR0dhbGx5OjpnZ3BhaXJzKHN0b3JlLCBjb2x1bW5zID0gYmFzZV9jb2x1bW5zKQ0KYGBgDQoNCmBgYHtyLCBtZXNzYWdlPUZBTFNFLCB3YXJuaW5nPUZBTFNFfQ0KR0dhbGx5OjpnZ3BhaXJzKHN0b3JlLCBjb2x1bW5zID0gYyhiYXNlX2NvbHVtbnMsICJZZWFyIiksDQogICAgICAgICAgICAgICAgbWFwcGluZyA9IGdncGxvdDI6OmFlcyhjb2xvciA9IFllYXIpKQ0KYGBgDQoNCmBgYHtyLCBtZXNzYWdlPUZBTFNFLCB3YXJuaW5nPUZBTFNFfQ0KR0dhbGx5OjpnZ3BhaXJzKGNhdGVnb3J5LCBjb2x1bW5zID0gYmFzZV9jb2x1bW5zLA0KICAgICAgICAgICAgICAgIG1hcHBpbmcgPSBnZ3Bsb3QyOjphZXMoY29sb3IgPSBDYXRlZ29yeSkpDQpgYGANCg0KYGBge3IsIG1lc3NhZ2U9RkFMU0UsIHdhcm5pbmc9RkFMU0V9DQpwIDwtIEdHYWxseTo6Z2dwYWlycyh0eXBlLCBjb2x1bW5zID0gY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